from tornado import template
import json


def compile_template(template_json, data_json, result_json):
    with open(template_json, encoding="utf-8") as Template, open(data_json, encoding="utf-8") as Json:
        t = template.Template(Template.read())
        jsondict = json.load(Json)
    with open(result_json, "w", encoding="utf-8") as target:
        target.write(str(t.generate(**jsondict), "utf-8"))
    result = str(t.generate(**jsondict))
    return result
